/** * author: sailing date: 2018/11/15 */

<template>
	<div>
		<mu-dialog title="添加" width="360" :open.sync="openSimple">
			<mu-container>
				<mu-form ref="form" :model="validateForm" class="mu-demo-form">
					<mu-form-item
						label="早餐类型"
						help-text=""
						prop="name"
						:rules="nameRules"
					>
						<mu-text-field
							v-model="validateForm.name"
							prop="name"
						></mu-text-field>
					</mu-form-item>

					<mu-form-item
						label="描述"
						help-text=""
						prop="describe"
						:rules="nameRules"
					>
						<mu-text-field
							v-model="validateForm.describe"
							prop="describe"
						></mu-text-field>
					</mu-form-item>
					
				
					<mu-form-item>
						<mu-button color="primary" @click="submit"
							>提交</mu-button
						>
					</mu-form-item>
				</mu-form>
			</mu-container>
			<mu-button
				slot="actions"
				flat
				color="primary"
				@click="addFood()"
				>关闭</mu-button
			>
		</mu-dialog>
	</div>
</template>

<script>
import eventBus from '../../server/eventBus.js'
import tools from '../../server/tools.js'
export default {
	data() {
		return {
			openSimple: false,
			nameRules: [
				{ validate: val => !!val, message: "请填写类型" }
			],

			
			argeeRules: [
				
			],
			validateForm: {
				name: "",
				id: '',
				describe: ""
			}
		};
	},
	mounted () {
		eventBus.$on('add_zaocan_panel', this.openSimpleDialog)
	},
	methods: {
		openSimpleDialog() {
			this.openSimple = true;
		},
		addFood() {
			this.openSimple = false;
		},
		submit() {
			this.validateForm['id'] = tools.uuid()
			var pdata = {
				id: tools.uuid(),
				name: this.validateForm['name'],
				select: false,
				text: '',
				describe: this.validateForm['name']
			}
			eventBus.$emit('add_zaocan_item', pdata)
			this.openSimple = false;
		}
	}
};
</script>

<style lang="less"></style>
